All Questions
Tagged with dynamic-programmingstrings
15 questions
3votes
1answer
271views
Longest Palindromic Substring | Python Code Giving TLE
Problem Statement Given a string s , return the longest palindromic substring in s. Constraints ...
1vote
2answers
141views
0votes
1answer
375views
Generate unique string permutations recursively
🧩 Objective Write a recursive method for generating all permutations of an input string. Return them as a set. See: Recursive String Permutations - Interview Cake 🔎 Questions 1: How does the ...
9votes
1answer
2kviews
LeetCode on Longest Palindromic Substring in Python
This is a programming question from LeetCode: Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Note: "aba" is ...
1vote
2answers
120views
A function to scan user input as string
I know that multiple functions are already available. However, I thought of writing my own because I wanted to learn the logic (and also because I thought there wasn't enough confusion :P). Please ...
2votes
1answer
82views
Length of the longest common sub sequence bottom up
Could I get some feedback on this code? I included a test case as well. This code computes the longest common sub sequence given paired data, it was not part of any challenge I just did it to learn ...
5votes
1answer
153views
Identify fraudulent bank transactions
Task: Return true if a transaction is allowed and return false if transaction is prohibited. Details: 1. String is represented as an "array" that can contain up to three elements. We need to ...
3votes
2answers
1kviews
Counting the number of ways to decode a string
I am working on problem where I need to decode a string: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... '...
2votes
0answers
1kviews
minimum window subsequence leetcode dynamic programming solution
Given strings S and T, find the minimum (contiguous) substring W of ...
6votes
2answers
2kviews
Length of longest palindrome subsequence
I had an interview, where I was asked to solve to this question: Given an string str, find the maximum length of palindrome subsequence. Example: >if str = 'abcda': maximum_length = 3 'aca' How ...
3votes
0answers
791views
Hackerrank: Sherlock and anagram (optimal time complexity)
Problem statement Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings. Input Format First line contains \$T\$, the number of testcases. Each testcase ...
3votes
1answer
111views
Given two words, transform the first one into the second [closed]
As the title says, the problem I had to do sounded something like this: We are given two words, S1 and S2. We must transform S1 into S2, using the following operations: insert: insert a character in ...
2votes
1answer
581views
Longest common substring using dynamic programming
I've written a short python script that attempts to solve the problem of finding the longest common substring using the dynamic programming technique. It is meant to be generalised so I could plug in ...
1vote
1answer
2kviews
Levenshtein distance with edit sequence and alignment in Java
I have this program that computes a Levenshtein distance of the two input strings, their edit sequence, and the alignment: LevenshteinEditDistance.java: ...
3votes
2answers
891views
Longest Common Subsequence and Longest Subsequence Palindrome
The following code computes: The longest common subsequence between two strings, where a subsequence of a sequence does not have to consist of contiguous elements of the sequence. The longest ...